<template>
    <rx-layout>
        <div slot="center" style>
            <rx-fit :isheader="isheader">
                <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
                    <div class="table-operator">
                        <a-button type="primary" icon="plus"  @click="add">{{$ti18('rxList.newBtn','新建')}}</a-button>
                        <a-button type="primary" icon="search"  @click="listPermission">{{i18n('list.viewListPermBtn','查看列表权限')}}</a-button>
                        <a-button type="primary" icon="search"  @click="groupPermission">{{i18n('list.viewUserGroupPermBtn','查看用户组权限')}}</a-button>
                    </div>
                    <span class="search-btn-box" v-if="!isheader">
                <span class="search-btn" @click.stop="searchshow"><i class="iconfont iconguolv"></i>{{$ti18('rxList.leachBtn','过滤')}}</span>
          </span>
                </div>
                <div btnalign="right" slot="searchbar" v-if="fitSearch" @search="search" @cancel="cancel"
                     @close="closeSearchbar">
                    <a-form :layout="colLayout">
                        <a-row :gutter="24">
                            <a-col :span="colSpan">
                                <a-form-item :label="$ti18('rxForm.name','名称')">
                                    <a-input :placeholder="$ti18('rxForm.name','名称','','input')" v-model="queryParam.Q_NAME__S_LK"/>
                                </a-form-item>
                            </a-col>
                        </a-row>
                    </a-form>
                </div>
                <rx-grid
                    ref="table"
                    :bordered="isBorder"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formBoPmt/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10', '30', '40']"
                    id-field="pmtId"
                    :loadDataOnstart="true"
                    @selectChange="onSelectChange"
                >
          <span slot="isLeftTree" slot-scope="{ text, record }">
            <a-tag :color="statusMap[text].color">
              <span>{{ statusMap[text].text }}</span>
            </a-tag>
          </span>
                    <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span  @click.stop="edit(record)">{{$ti18('rxList.editBtn','编辑')}}</span>
            <span  @click.stop="delByIds([record.pmtId])">{{$ti18('rxList.delBtn','删除')}}</span>
          </span>
                </rx-grid>
            </rx-fit>
        </div>
    </rx-layout>
</template>

<script>
import FormBoPmtEdit from './FormBoPmtEdit';
import FormBoPmtListPermission from './FormBoPmtListPermission';
import FormBoPmtGroupPermission from './FormBoPmtGroupPermission';
import FormBoPmtApi from '@/api/form/core/formBoPmt';



import {BaseList} from "@lowcode/jpaas-common-lib"

import {Util} from "@lowcode/jpaas-common-lib"

export default {
    name: 'FormBoPmtList',
    mixins: [BaseList],
    components: {

    },
    data() {
        return {
            columns: [
                {title: this.$ti18('rxList.index','序号'), type: 'indexColumn', width: 80, dataIndex: 'serial', scopedSlots: {customRender: 'serial'}},
                {title: this.$ti18('rxForm.name','名称'), dataIndex: 'name', width: 200},
                {title: this.i18n('form.boListName','数据列表名称'), dataIndex: 'boListName', width: 200},
                {title: this.$ti18('rxForm.createTime','创建时间'), dataIndex: 'createTime', width: 140},
                {title: this.$ti18('rxList.action','操作'), dataIndex: 'action', scopedSlots: {customRender: 'action'}, width: 80},
            ],
            comment: this.i18n('list.comment','系统自定义业务管理列表'),
            widthHeight: ['1000px', '600px'],
            curTree: {},
            QueryData: {},
            statusMap: {
                'YES': {color: 'green', text: this.i18n('form.yes','是')},
                'NO': {color: 'blue', text: this.i18n('form.no','否')}
            }
        }
    },
    created() {
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"FormBoPmt",key);
        },
        delById(id) {
            return FormBoPmtApi.del(id)
        },
        refresh() {
            this.$refs.table.loadData();
        },
        add() {
            var conf = {
                component: FormBoPmtEdit,
                title: this.i18n('list.addDataAuthTitle','新增数据权限'),
                widthHeight: ['1140px', '600px']
            };
            var baseConf = {
                curVm: this,
                data: {
                    type: "add"
                }
            };
            let config = Object.assign(baseConf, conf);
            let _self =this;
            Util.open(config,function (action){
                if(action!='ok'){
                    return;
                }
                _self.refresh();

            });

        },
        edit(record) {
            var conf = {
                component: FormBoPmtEdit,
                title: this.i18n('list.editDataAuthTitle','编辑数据权限'),
                widthHeight: ['1140px', '600px']
            };
            var baseConf = {
                curVm: this,
                data: {
                    pkId: record.pkId,
                    type: "edit"
                }
            };
            let config = Object.assign(baseConf, conf);
            let _self =this;
            Util.open(config,function(action){
                if(action!='ok'){
                    return;
                }
                _self.refresh();

            });

        },

        search() {
            this.$refs.table.loadData();
        },
        cancel() {
            this.resetSearch();
        },
        closeSearchbar() {
            //关闭过滤弹窗；（点击X触发）
            this.fitSearch = false;
        },
        listPermission(){
            var conf = {
                component: FormBoPmtListPermission,
                title: this.i18n('list.viewListPermBtn','查看列表权限'),
                widthHeight: ['1140px', '600px']
            };
            var baseConf = {
                curVm: this,
                data: {
                }
            };
            let config = Object.assign(baseConf, conf);
            Util.open(config,function(action){
            });
        },
        groupPermission(){
            var conf = {
                component: FormBoPmtGroupPermission,
                title: this.i18n('list.viewUserGroupPermBtn','查看用户组权限'),
                widthHeight: ['1140px', '600px']
            };
            var baseConf = {
                curVm: this,
                data: {
                }
            };
            let config = Object.assign(baseConf, conf);
            Util.open(config,function(action){
            });
        }

    },
}
</script>
<style scoped>

</style>

